package com.example.jdbc_demo.mapper;

import com.example.jdbc_demo.entity.User;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from user where id = #{id}")
    public User getUser(int id);

    @Select("select * from user where username= #{username}")
    public User getUserByName(String username);

    @Select("select * from user limit #{limit} offset #{offset}")
    public List<User> getUserBypage1(int limit, int offset);

    @Select("select * from user limit #{start},#{size}")
    public int getUserByPage(int start, int size);

    @Insert("insert into user(id,username,password) values(#{id},#{name},#{password})")
    public int addUser(int id, String name, String password);

    @Delete("delete from user where id = #{id}")
    public int deleteUser(Integer id);

    @Update("update user set username = #{username}")
    public int updateUser(String username);

    @Select("select * from user")
    public List<User> getAll();
}
